<%--
    Document   : MyTwitter
    Created on : 18/Nov/2009, 0:08:48
    Author     : ziza
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean class="Cliente.WebGestor" id="webMyTwi" scope="session"/>

<%
            String username = null;
            String password = null;
            String op = request.getParameter("Operacao");
            System.out.println(op);
            if ("Login".equalsIgnoreCase(op)) {
                username = request.getParameter("nickName");
                password = request.getParameter("passWord");
                webMyTwi.efectuaLogin(username, password);
            }

            if ("Regist".equalsIgnoreCase(op)) {
                username = request.getParameter("username");
                password = request.getParameter("password");
                String repeat_password = request.getParameter("repeat_password");
                String first_name = request.getParameter("first_name");
                String last_name = request.getParameter("last_name");
                String local = request.getParameter("local");
                String email = request.getParameter("email");
                if (password.equals(repeat_password)) {
                    webMyTwi.efectuaRegisto(username, password, first_name.concat(" " + last_name), local, email);
                }
            }
            if (!webMyTwi.isLog()){%>
                <jsp:forward page="Login.jsp" />
<%          }
            if ((username.equals("admin")) && (webMyTwi.isLog())){%>
                <jsp:forward page="Backoffice.jsp" />
<%          }%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>MyTwitter - <%= username %></title>
    </head>

    <body style="background-image:url('IMG/mytwitter-bg.png'); background-repeat:repeat; background-attachment:fixed">
        <br>
        <div align="center">
            <table border="0">
                <tbody>
                    <tr>
                        <td><img src="IMG/mytwitter-logo.png" width="444" height="80" alt="mytwitter-logo" align="left"/></td>
                        <td align="right">
                            <form name="Logout" action="Login.jsp" method="post" >
                                <input type="submit" value="Logout" name="logout" align="right"/>
                            </form>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <form name="Twittar" action="submit_twitt.jsp" target="garbage_can" method="post" >
                                <table>
                                    <tbody>
                                        <tr>
                                            <td><img src="IMG/mytwitter-oqsepassa.png" alt="mytwitter-oqsepassa" style="vertical-align:middle"/></td>
                                            <td><input type="text" style="color:gray; background:transparent; background-image:url(IMG/bg-txt.png);background-repeat:repeat" name="tweet" value="" size="41" maxlength="140"/></td>
                                            <td><input type="submit" value="Twittar" name="twittar" /></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <iframe src="twits_client.jsp" width="610" frameborder="0" scrolling="0" height="440" name="twits" ></iframe>
                        </td>
                        <td>
                            <table border="0">
                                <tbody>
                                    <tr>
                                        <td><img src="IMG/mytwitter-followers.png" alt="mytwitter-followers"/></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <iframe src="followers_client.jsp" width="200" frameborder="0" scrolling="0" height="100" ></iframe>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><img src="IMG/mytwitter-following.png" alt="mytwitter-following"/></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <iframe src="following_client.jsp" width="200" frameborder="0" scrolling="0" height="100" ></iframe>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <form name="Search" action="search_client.jsp" target="search_frame" method="post" >
                                                <input type="text" style="color:gray; background:transparent; background-image:url(IMG/bg-txt.png);background-repeat:repeat" name="lookingforsomeone" size="14"/>
                                                <input type="submit" value="Search" name="search" />
                                            </form>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <iframe src="" width="425" frameborder="0" scrolling="0" height="125" name="search_frame"></iframe>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <iframe src="" width="0" frameborder="0" scrolling="0" height="0" name="garbage_can" ></iframe>
    </body>
</html>
